<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<script type="text/javascript">
	function movePage(pageNo) {
		$.get("myMsgList.do?pageNo=" + pageNo + param()
				+'&'+ Math.random(), function(data) {
			$("#main").html(data);
		});
	}
	function del(id){
		$.get("deleteMsg.do?id="+id,function(data){
			alert(data);
		});
		movePage(${param.pageNo});
	}
	function param() {
		var param = "";
		if ($("#classCode").val() != "")
			param += '&classCode=' + $("#classCode").val();
		if ($("#title").val() != "")
			param += '&title=' + $("#title").val();
		if ($("#description").val() != "")
			param += '&description=' + $("#description").val();
		return param;
	}
	$(document).ready(function() {
		$.get("getSelect.do", {
			type : 'ms',
			index : '${param.classCode}',
			code : null
		}, function(data) {
			$("select#classCode").append(data);
		});
		$("#search").button().click(function() {
			movePage(1);
		});
		$("#add").button().click(function() {
			window.open('addMsg.do', '', '');
		});
	});
</script>

	<div class="search">
		<label>
			类别：
		</label>
		<select id="classCode">
			<option value="">
				不限制
			</option>
		</select>
		<label>
			标题：
		</label>
		<input type="text" name="title" id="title" value="${param.title }" />
		<label>
			内容：
		</label>
		<input type="text" name="description" id="description"
			value="${param.description }" />
		<button id="search">
			查询
		</button>
		<button id="add">
			发布
		</button>
	</div>
	<ul>
		<c:forEach var="e" items="${o.dataList}" varStatus="s">
			<li>
				【${e.className}】
				<a href="showMsg.do?id=${e.id}" target="_blank">${e.title }</a>
				<span class="date"><fmt:formatDate value="${e.inputdate}"
						pattern="yyyy/MM/dd" /> </span>
				<a href="javascript:if(confirm('确定删除？'))del('${e.id}')">删除</a>
			</li>
		</c:forEach>
	</ul>
	${o.pageNav }

